﻿using System;
using System.Collections.Generic;
using LiSA_Server.Base.NHibernate.Models;
using NHibernate;
using NHibernate.Mapping.ByCode.Conformist;

namespace LiSA_Service.ResearchProjects.Models
{
    public class ResearchProject : Entity
    {
        public virtual Guid ProjectLead { get; set; }
        public virtual int MajorityNumber { get; set; }

        public virtual ICollection<Guid> Users { get; set; }

        /// <summary>
        /// Masterlist of articles. This list should NEVER be deleted from or modified, only added to!
        /// </summary>
        public virtual ICollection<Guid> ArticlesMasterlist { get; set; }

        public virtual ICollection<Guid> Articles { get; set; }

        public virtual ICollection<Guid> RemovedArticles { get; set; }

        public virtual ICollection<ProjectStage> Stages { get; set; }

        public virtual ICollection<ProjectCriteria> Criteria { get; set; }

        public virtual ICollection<ResearchQuestion> ResearchQuestions { get; set; }

        public virtual ICollection<ProjectSearchString> SearchStrings { get; set; }

        public virtual ICollection<string> SearchKeyWords { get; set; }

        public virtual string Description { get; set; }

        public virtual string Title { get; set; }

        public virtual int CurrentPhase { get; set; }

        public virtual bool IsActive { get; set; }

        public virtual ICollection<ProjectSettings> Settings { get; set; }
    }

    /// <summary>
    /// The ArticleFeedback mapping.
    /// </summary>
    public class ResearchProjectMapping : ClassMapping<ResearchProject>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ResearchProjectMapping"/> class.
        /// </summary>
        public ResearchProjectMapping()
        {
            this.Property(x => x.ProjectLead);
            this.Property(x => x.MajorityNumber);
            this.Set(x => x.Users, m => { }, r => r.Element());
            this.Set(x => x.ArticlesMasterlist, m => { }, r => r.Element());
            this.Set(x => x.Articles, m => { }, r => r.Element());
            this.Set(x => x.RemovedArticles, m => { }, r => r.Element());
            this.Set(x => x.Stages, m => { m.Cascade(NHibernate.Mapping.ByCode.Cascade.All); }, r => r.Element());
            this.Set(x => x.Criteria, m => { m.Cascade(NHibernate.Mapping.ByCode.Cascade.All); }, r => r.Element());
            this.Set(x => x.ResearchQuestions, m => { m.Cascade(NHibernate.Mapping.ByCode.Cascade.All); }, r => r.Element());
            this.Set(x => x.SearchStrings, m => { m.Cascade(NHibernate.Mapping.ByCode.Cascade.All); }, r => r.Element());
            this.Set(x => x.SearchKeyWords, m => { }, r => r.Element());
            this.Property(x => x.Description, x => x.Type(NHibernateUtil.StringClob));
            this.Property(x => x.Title, x => x.Type(NHibernateUtil.StringClob));
            this.Property(x => x.CurrentPhase);
            this.Set(x => x.Settings, m => { m.Cascade(NHibernate.Mapping.ByCode.Cascade.All); }, r => r.Element());
        }
    }
}